import cv2 as cv 
import argparse
import numpy as np 

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-f", "--file", help="image name", type=str, default="./23_8.png")
    parser.add_argument("-off", "--offset", help="offset value for the input", type=int, default=128)
    parser.add_argument("-scl", "--scale", help="scale value for the input", type=int, default=128)
    args, unknown = parser.parse_known_args()

    path = args.file
    offset = args.offset
    scale = args.scale 

    img = cv.imread(path).astype("float32")
    img = img[...,(2,0,1)]

    img = ((img - offset) / scale * 1.0)


    img_bytes = img.tobytes(order='C')

    with open("image.bin", 'wb') as f:
        print("TotalBytes ", f.write(img_bytes))
        f.close()